package com.Example;

import java.util.Random;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

public class Bullet extends BaseBoxObject{

	
	private static final float WIDTH = 0;
	private static final float HEIGHT = 0;
	private static final float RADIUS = 7;
	private static final float DENSITY = 10;
	private static final float RESTITUTION = 0;
	private Vector2 pos;
	private TextureWrapper texture;


	public Bullet(int bodyIndex, int collisionGroup, float px, float py, float angle) {
			super(bodyIndex, collisionGroup);
			this.pos=new Vector2(px,py);
			BodyType bodyType = BodyType.DynamicBody;
			this.MakeBody(WIDTH, HEIGHT, RADIUS, bodyType, DENSITY, RESTITUTION, pos, angle);
			body.setGravityScale(0);
			body.setBullet(true);
			this.texture = new TextureWrapper(Assets.ballRegion, pos);
			Vector2 force= new Vector2();
			force.x=(float) (-100*(float) Math.cos((angle-90)*3.1415/180));
			force.y=(float) (-100* (float)Math.sin((angle-90)*3.1415/180));
//			force.x=5;
//			force.y=10;

			body.setLinearVelocity(force);
	}

	
	//int bodyIndex, int collisionGroup, float px, float py, float angle
	@Override
	public void Draw(SpriteBatch sp) {
		// TODO Auto-generated method stub
		if(IsAlive){
			texture.Draw(sp);
		}
	}

	
	public void Update(float dt){
		if(IsAlive){
			super.Update(dt);
			
			
			
			texture.Position.set(bodyWorldPosition);
		}
		
	}
	
	
	public void SetTextureDimension(int width,int height){
		texture.SetDimension(width, height);

	}
	
	
}
